package com.net.xpay.backend.scheduler;


import com.net.xpay.common.manager.notify.SafePayBatchNotifyRecordManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * 2019/7/15 16:28

 * 安全付回调通知
 */
@Slf4j
@Component
public class SafePayNotifyRecordScheduler {

    @Autowired
    private SafePayBatchNotifyRecordManager safePayBatchNotifyRecordManager;


    /**
     * 清理过期的数据
     */
    @Scheduled(cron = "0 0 2 * * *")
    public void cleanSafePayBatchNotifyRecord() {
        log.info("cleanSafePayBatchNotifyRecord start");

        LocalDateTime deadline = LocalDateTime.now().minusDays(3L);
        safePayBatchNotifyRecordManager.deleteFinishedRecord(deadline);

        log.info("cleanSafePayBatchNotifyRecord end");
    }

}
